import type {
  ConsultOrderPreData,
  ConsultOrderPreParams,
  DoctorPage,
  FollowType,
  Image,
  KnowledgePage,
  KnowledgeParams,
  PageParams,
  PartialConsult,
  TopDep
} from '@/types/consult'
import { request } from '@/utils/request'

// 获取首页文章列表
export const getKnowledgeList = (pramas: KnowledgeParams) =>
  request<KnowledgePage>('/patient/home/knowledge', 'GET', pramas)

// 获取关注医生列表
export const getDoctorList = (pramas: PageParams) =>
  request<DoctorPage>('/home/page/doc', 'GET', pramas)

// 关注和取消关注
export const followDoctor = (id: string, type: FollowType) => request('/like', 'POST', { id, type })

// 获取科室列表数据
export const getAllDep = () => request<TopDep[]>('/dep/all', 'GET')

// 上传病情描述图片
export const uploadImg = (file: File) => {
  const fd = new FormData()
  fd.append('file', file)
  return request<Image>('/upload', 'POST', fd)
}

// 获取预支付信息
export const getConsultOrderPre = (params:ConsultOrderPreParams) =>
  request<ConsultOrderPreData>('/patient/consult/order/pre', 'GET', params)

  // 生成订单接口
export const createConsultOrder = (params: PartialConsult) =>
request<{ id: string }>('/patient/consult/order', 'POST', params)

// 支付接口
export const getConsultOrderPayUrl = (params: {
  paymentMethod: number
  orderId: string
  payCallback: string
}) => request<{ payUrl: string }>('/patient/consult/pay', 'POST', params)